From b0cc27c30b047aaf3e46d01b1ff21d39a3742c88 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 21 Sep 2007 15:38:29 +0000 Subject: [PATCH] Some more fixed to prevent segfaults with missing or nonsensical ranges. 2007-09-21 Matthias Clasen * gtk/gtkprintoperation.c (print_pages_idle): Some more fixed to prevent segfaults with missing or nonsensical ranges. svn path=/trunk/; revision=18854 --- ChangeLog | 5 +++++ gtk/gtkprintoperation.c | 16 +++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5132cb72be..0fe14d327b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-21 Matthias Clasen + + * gtk/gtkprintoperation.c (print_pages_idle): Some more + fixed to prevent segfaults with missing or nonsensical ranges. + 2007-09-21 Jean Brefort * gtk/gtkprintoperation.c: (print_pages_idle): abort printing diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 1c3a1901f0..4519cd24fb 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -2090,23 +2090,21 @@ print_pages_idle (gpointer user_data) goto out; } - /* FIXME handle this better */ - if (priv->nr_of_pages == 0) - g_warning ("no pages to print"); - /* Initialize parts of PrintPagesData that depend on nr_of_pages */ if (priv->print_pages == GTK_PRINT_PAGES_RANGES) { - if (priv->page_ranges == NULL) { - g_warning ("no pages to print"); - priv->cancelled = TRUE; - goto out; + if (priv->page_ranges == NULL) + { + g_warning ("no pages to print"); + priv->cancelled = TRUE; + goto out; } data->ranges = priv->page_ranges; data->num_ranges = priv->num_page_ranges; for (i = 0; i < data->num_ranges; i++) - if (data->ranges[i].end == -1) + if (data->ranges[i].end == -1 || + data->ranges[i].end >= priv->nr_of_pages) data->ranges[i].end = priv->nr_of_pages - 1; } else if (priv->print_pages == GTK_PRINT_PAGES_CURRENT && -- 2.30.2